﻿/**
 * Jean-François Desgagné 2009 Portfolio
 * Copyright (c) 2009 Jean-François Desgagné <jfesgagne@gmail.com>
 * 
 * This work is licensed under a Creative Commons Attribution 3.0 United States License.
 * Some Rights Reserved.
 */
package com.jfdesgagne.jfdesgagne09.shell {
    import org.puremvc.as3.multicore.interfaces.IFacade;
    import org.puremvc.as3.multicore.patterns.facade.Facade;
    import com.jfdesgagne.jfdesgagne09.shell.controller.*;
	
	
    
    public class ApplicationFacade extends Facade implements IFacade{
        // Notification name constants
		public static const NAME:String  				= "shellFacade";
        public static const STARTUP:String  			= "startup";
        public static const INITIALIZE:String  			= "initialize";
        public static const SECTION_CHANGED:String  	= "sectionChanged";
		public static const RESIZE:String  				= "resize";
		public static const LOCALPROXY_LOADED:String	= "localProxyLoaded";
		public static const CONFIGPROXY_LOADED:String 	= "configProxyLoaded";
		public static const SHOW_TOOLTIP:String 		= "showTooltip";
		public static const HIDE_TOOLTIP:String 		= "hideTooltip";
		public static const OPEN_LOADING:String 		= "openLoading";
		public static const CLOSE_LOADING:String 		= "closeLoading";
		public static const OPEN_SHOWCASE:String 		= "openShowcase";
		

		public function ApplicationFacade(key:String) {
			super(key);	
		}
		
        public static function getInstance(key:String) : ApplicationFacade {
 			if (instanceMap[key] == null) instanceMap[key]  = new ApplicationFacade(key);
 			return ApplicationFacade(instanceMap[key]);
        }

         override protected function initializeController() : void {
            super.initializeController(); 
			this.registerCommand(STARTUP, StartupCommand);
			this.registerCommand(CONFIGPROXY_LOADED, LoadLocaleCommand);
			this.registerCommand(LOCALPROXY_LOADED, PrepAppCommand);
			this.registerCommand(SECTION_CHANGED, ChangeSectionCommand);
			this.registerCommand(OPEN_SHOWCASE, OpenShowcaseCommand);
			this.registerCommand(OPEN_LOADING, OpenLoadingCommand);
			this.registerCommand(CLOSE_LOADING, CloseLoadingCommand);
        }
		
        public function startup( stage:Object ):void {
        	this.sendNotification(STARTUP, stage);
        }
    }
}